package com.mvvm.ktnet.ext

import com.alibaba.fastjson.JSON
import com.alibaba.fastjson.JSONObject
import nethttp.RxHttpJsonParam
import rxhttp.IAwait
import rxhttp.newAwait

/**
 *
 * @ProjectName:    KtNet
 * @Package:        com.mvvm.ktnet.ext
 * @ClassName:      RxhttpExt
 * @Description:     java类作用描述
 * @Author:         Alex
 * @CreateDate:     2020/11/12 10:00
 * @UpdateUser:     更新者：
 * @UpdateDate:     2020/11/12 10:00
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */
fun RxHttpJsonParam.addBean(any: Any): RxHttpJsonParam {
    for ((key, value) in JSONObject.parseObject(JSON.toJSONString(any))) {
        add(key, value)
    }
    return this
}

/**
 * @method
 * @description 取最后几条数据
 * @date: 2020/8/4 13:47
 * @author: 作者名
 * @param
 * @return
 */
fun <T> IAwait<out List<T>>.takeLast(
    count: Int
): IAwait<List<T>> = newAwait {
    await().takeLast(count)
}